﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using TimberSmart.Business;
using TimberSmart.Business.Contracts;
using TimberSmart.Model.Security;

namespace TimberSmart.Web.Controllers
{
    //[Authorize]
    //[RequireBasicAuth]
    public class UserController : ApiController
    {
        private readonly UserService _userService;

        public UserController(UserService userService)
        {
            _userService = userService;
        }

        // GET api/user
        public IResponse<User> Get()        
        {
            return _userService.FindAllUsers(AuthToken.CreateToken(Request.Headers.Authorization));
        }

        // GET api/user/5
        public string Get(int id)
        {
            return null;
        }

        // POST api/user
        public IResponse<User> Post([FromBody]string value)
        {

            var headers = Request.Headers;

            return _userService.FindAllUsers(AuthToken.CreateToken(Request.Headers.Authorization));
        }

        // PUT api/user/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/user/5
        public void Delete(int id)
        {
        }
    }
}
